package system.task;

import system.task.errors.TaskException;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 任务管理器
 */
public interface TaskManager {

    void start() throws TaskException;

    void stop() throws TaskException;

    void pause() throws TaskException;

    void resume() throws TaskException;

    void pause(String name) throws TaskException;

    void resume(String name) throws TaskException;

    Task getTask(String name) throws TaskException;

    /**
     * 添加任务
     *
     * @param task
     * @return true 添加成功或修改成功 , false 已存在相同任务
     * @throws TaskException
     */
    boolean addTask(Task task) throws TaskException;

    /**
     * 获取触发时间列表
     *
     * @param name
     * @param size
     * @param afterTime
     * @return
     * @throws TaskException
     */
    List<Date> getTriggerTimes(String name, int size, Date afterTime) throws TaskException;

    void delTask(String name) throws TaskException;

    void startTask(String name, Map param) throws TaskException;

    void stopTask(String name) throws TaskException;

    void cleanNoContain(Set<String> nameList);

    boolean isRunning(String name);

}
